﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Verifications;

namespace Pixysoft.Framework.Logs
{
    class GroupLoggerSetting : ILoggerSetting
    {
        List<ILoggerSetting> settings = null;

        public GroupLoggerSetting(List<ILoggerSetting> settings)
        {
            this.settings = settings;
        }

        public string Filename
        {
            get
            {
                if (settings.Count != 1)
                    throw Exceptions.ManualVerificationFailedException("not support in group logger setting");

                return settings[0].Filename;
            }
        }

        public string Modulename
        {
            get
            {
                if (settings.Count != 1)
                    throw Exceptions.ManualVerificationFailedException("not support in group logger setting");

                return settings[0].Modulename;
            }
        }

        public bool PrintToConsole
        {
            get
            {
                throw Exceptions.ManualVerificationFailedException("not support in group logger setting");
            }
            set
            {
                foreach (ILoggerSetting setting in settings)
                {
                    setting.PrintToConsole = value;
                }
            }
        }

        public long LogCapacity
        {
            get
            {
                throw Exceptions.ManualVerificationFailedException("not support in group logger setting");
            }
            set
            {
                foreach (ILoggerSetting setting in settings)
                {
                    setting.LogCapacity = value;
                }
            }
        }

        public LogLevel LogLevel
        {
            get
            {
                throw Exceptions.ManualVerificationFailedException("not support in group logger setting");
            }
            set
            {
                foreach (ILoggerSetting setting in settings)
                {
                    setting.LogLevel = value;
                }
            }
        }

        public string LogPath
        {
            get
            {
                if (settings.Count != 1)
                    throw Exceptions.ManualVerificationFailedException("not support in group logger setting");

                return settings[0].LogPath;
            }
            set
            {
                foreach (ILoggerSetting setting in settings)
                {
                    setting.LogPath = value;
                }
            }
        }

        public string GetLogFilePath()
        {
            if (settings.Count != 1)
                throw Exceptions.ManualVerificationFailedException("not support in group logger setting");

            return settings[0].GetLogFilePath();
        }

        public string GetLogFilename()
        {
            if (settings.Count != 1)
                throw Exceptions.ManualVerificationFailedException("not support in group logger setting");

            return settings[0].GetLogFilename();
        }
    }
}
